<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Administrar</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        {% load staticfiles %} <link rel="stylesheet" href="{% static "css/spacelab.css" %}">
        {% load staticfiles %} <link rel="stylesheet" href="{% static "css/responsive.css" %}">
        {% load staticfiles %} <link rel="stylesheet" href="{% static "css/misestilos.css" %}">
        {% load staticfiles %} <link rel="stylesheet" href="{% static "css/formhelpers.css" %}">
        {% load staticfiles %} <link rel="stylesheet" href="{% static "css/menu_jquery.css" %}">
    </head>
    <body>
        {% csrf_token %}
        {% include "topmenu.html" %}

        <div class="container">
            <div class="row-fluid">

                {% include "sidebar.html" %} <!-- Side bar -->

                <div class="span9">
                    <div class="page-header">
                        <h2>Administrar Usuarios de la Universidad</h2>
                        <h4>{{ universidad.nombre }}</h4>
                    </div>

                    <div class="row-fluid">
                        {% if info == 'Error'%}
                            <div class="alert alert-error">
                                <button type="button" class="close" data-dismiss="alert">&times;</button>
                                <strong>Error!</strong> Ha ocurrido un error durante la operación
                            </div>
                        {%endif%}
                        {% if info == 'Guardado'%}
                            <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">&times;</button>
                                La operación se ha realizado con éxito!
                            </div>
                        {%endif%}

                        <div class="span12"><!-- Muestra Usuarios -->

                            {{ datos | safe }}

                        </div><!-- /span12 -->
                    </div><!-- /row-fluid -->
                </div><!-- /span9 -->

                <!-- Modal Eliminar-->
                <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                     <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">Alert!</h3>
                     </div>
                     <div class="modal-body">
                        <p>¿Está seguro que desea eliminar este usuario?</p>
                     </div>
                     <div class="modal-footer">
                        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                        <a class="btn btn-primary" id="PopUp_Save">Eliminar</a>
                     </div>
                </div><!-- Modal Eliminar-->

            </div><!-- /row-fluid -->
            {% include "footer.html" %} <!-- Footer -->
        </div><!-- /container -->

        <!-- JS files -->
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/jquery.js" %}"></script>
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/bootstrap.js" %}"></script>
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/ajax.js" %}"></script>
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/validarEmail.js" %}"></script>
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/popupMensaje.js" %}"></script>
        {% load staticfiles %} <script type="text/javascript" src="{% static "js/menu_jquery.js" %}"></script>

        <script>
            function eliminar(user_id){
                $('#myModal').modal('show');
                $("#PopUp_Save").attr("href", "/plataforma/usuarios/administrar/"+user_id+"");
            }

            function ajax_guardar(checkboxid, id){
                if ($('#'+checkboxid).checked){
                    //activar al usuario
                    $.ajax({
                        type:"POST",
                        url:"/plataforma/usuarios/administrar/"+id+"/",
                        data:{'csrfmiddlewaretoken': document.getElementsByName('csrfmiddlewaretoken')[0].value, 'activar': '1'}
                    });
                }else{
                    //desactivar
                    $.ajax({
                        type:"POST",
                        url:"/plataforma/usuarios/administrar/"+id+"/",
                        data:{'csrfmiddlewaretoken': document.getElementsByName('csrfmiddlewaretoken')[0].value, 'activar': '0'}
                    });
                }
            }
        </script>
    </body>
</html>
